from appium import webdriver
from framework.logger import MyLog

# 实例化日志
log = MyLog.get_log()
logger = log.getlog()


class OpenApp(object):

    def __init__(self, driver):
        self.driver = driver

    def open_app(self):
        desired_caps = {"platformName": "Android", "platformVersion": "5.1.1", "deviceName": "127.0.0.1:62001",
                           "appPackage": "com.gelonghui.glhapp",'noReset':'True','automationName':'UiAutomator1', \
                        'noSign':'True',
                        "appActivity": "com.gelonghui.glhapp.components.mainpage.MainActivity",
                        'unicodeKeyboard':'true',
                        'resetKeyboard': 'true'
                        }
        self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
        logger.info("打开app")
        driver = self.driver
        return driver

    def quit_app(self):
        logger.info("退出app")
        self.driver.quit()
